/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Logik.*;
import javax.swing.*;
import Interfaces.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Beinhaltet Medienverwaltungsfenster und die jeweiligen Events
 * @author Sebastian
 */
public class MedienverGUI extends javax.swing.JFrame {

    /**
     * Creates new form MedienverGUI
     */
    public MedienverGUI() {
        initComponents();
    }
    
    Interfaces.Medienverwaltung mv = new Medienquelle();
    List<Medium> list = mv.getListe();

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbl_medienver_artikelnummer = new javax.swing.JLabel();
        lbl_medienver_medium = new javax.swing.JLabel();
        lbl_medienver_titel = new javax.swing.JLabel();
        lbl_medienver_genre = new javax.swing.JLabel();
        lbl_medienver_regisseur = new javax.swing.JLabel();
        lbl_medienver_hauptdarsteller = new javax.swing.JLabel();
        lbl_medienver_preis = new javax.swing.JLabel();
        lbl_medienver_drei_d_modus = new javax.swing.JLabel();
        lbl_medienver_online = new javax.swing.JLabel();
        txt_medienver_artikelnummer = new javax.swing.JTextField();
        txt_medienver_titel = new javax.swing.JTextField();
        txt_medienver_hauptdarsteller = new javax.swing.JTextField();
        txt_medienver_preis = new javax.swing.JTextField();
        check_medienver_drei_d = new javax.swing.JCheckBox();
        check_medienver_online = new javax.swing.JCheckBox();
        but_medienver_anlegen = new javax.swing.JButton();
        but_medienver_suchen = new javax.swing.JButton();
        but_medienver_loeschen = new javax.swing.JButton();
        but_medienver_zurueck = new javax.swing.JButton();
        lbl_medienver_move = new javax.swing.JLabel();
        lbl_medienver_gamepad = new javax.swing.JLabel();
        lbl_medienver_kinect = new javax.swing.JLabel();
        check_medienver_move = new javax.swing.JCheckBox();
        check_medienver_kinect = new javax.swing.JCheckBox();
        check_medienver_gamepad = new javax.swing.JCheckBox();
        lbl_medienver_medienliste = new javax.swing.JLabel();
        txt_medienver_genre = new javax.swing.JTextField();
        combo_medienver_medium = new javax.swing.JComboBox();
        lbl_medienver_preis_euro = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        list_medienver_medienliste = new javax.swing.JList();
        txt_medienver_regisseur = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Medienverwaltung");

        lbl_medienver_artikelnummer.setText("Artikelnummer:");

        lbl_medienver_medium.setText("Medium:");

        lbl_medienver_titel.setText("Titel:");

        lbl_medienver_genre.setText("Genre:");

        lbl_medienver_regisseur.setText("Regisseur (Filme):");

        lbl_medienver_hauptdarsteller.setText("Hauptdarsteller (Filme):");

        lbl_medienver_preis.setText("Preis (z.B. 3.00):");

        lbl_medienver_drei_d_modus.setText("3D-Modus (Blue Ray):");

        lbl_medienver_online.setText("Online-Modus(Spiele):");

        txt_medienver_artikelnummer.setToolTipText("Keine Buchstaben");

        check_medienver_drei_d.setText("Ja");

        check_medienver_online.setText("Ja");

        but_medienver_anlegen.setText("Anlegen");
        but_medienver_anlegen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                but_medienver_anlegenMouseClicked(evt);
            }
        });

        but_medienver_suchen.setText("Suchen");
        but_medienver_suchen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                but_medienver_suchenMouseClicked(evt);
            }
        });

        but_medienver_loeschen.setText("Löschen");
        but_medienver_loeschen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                but_medienver_loeschenMouseClicked(evt);
            }
        });

        but_medienver_zurueck.setText("Zurück");
        but_medienver_zurueck.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                but_medienver_zurueckMouseClicked(evt);
            }
        });

        lbl_medienver_move.setText("PS-Move:");

        lbl_medienver_gamepad.setText("WiiU Gamepad:");

        lbl_medienver_kinect.setText("XBOX-Kinect:");

        check_medienver_move.setText("Ja");

        check_medienver_kinect.setText("Ja");

        check_medienver_gamepad.setText("Ja");

        lbl_medienver_medienliste.setText("Medienliste:");

        combo_medienver_medium.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "DVD", "Blue Ray", "PS 3", "Wii U", "X-Box" }));

        lbl_medienver_preis_euro.setText("€");

        list_medienver_medienliste.setModel(new MediaListModel(list));
        jScrollPane2.setViewportView(list_medienver_medienliste);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_medienver_preis, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_medienver_drei_d_modus, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(32, 32, 32)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(check_medienver_drei_d)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(txt_medienver_preis, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lbl_medienver_preis_euro))))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_medienver_hauptdarsteller, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_medienver_regisseur, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_medienver_genre, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_medienver_titel, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_medienver_medium, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(combo_medienver_medium, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_medienver_titel, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_medienver_genre, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_medienver_regisseur, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_medienver_hauptdarsteller, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_medienver_artikelnummer, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lbl_medienver_medienliste, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(lbl_medienver_gamepad, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
                                            .addComponent(lbl_medienver_kinect, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(lbl_medienver_move, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(lbl_medienver_online, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(check_medienver_online)
                                                    .addComponent(check_medienver_move, javax.swing.GroupLayout.Alignment.TRAILING))
                                                .addComponent(check_medienver_kinect, javax.swing.GroupLayout.Alignment.TRAILING))
                                            .addComponent(check_medienver_gamepad, javax.swing.GroupLayout.Alignment.TRAILING))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(but_medienver_anlegen, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(but_medienver_suchen, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(but_medienver_loeschen, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(but_medienver_zurueck, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGap(30, 30, 30))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbl_medienver_artikelnummer, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_medienver_artikelnummer, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_medienver_artikelnummer, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_medienver_medium, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(but_medienver_anlegen, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_medienver_online, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(check_medienver_online)
                    .addComponent(combo_medienver_medium, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_medienver_titel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_medienver_titel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(but_medienver_suchen, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_medienver_move, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(check_medienver_move))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_medienver_genre, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(but_medienver_loeschen, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_medienver_kinect, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(check_medienver_kinect)
                    .addComponent(txt_medienver_genre, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_medienver_regisseur, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(but_medienver_zurueck, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_medienver_gamepad, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(check_medienver_gamepad)
                    .addComponent(txt_medienver_regisseur, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lbl_medienver_medienliste)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbl_medienver_hauptdarsteller, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txt_medienver_hauptdarsteller, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbl_medienver_preis, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txt_medienver_preis, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbl_medienver_preis_euro, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbl_medienver_drei_d_modus, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(check_medienver_drei_d)))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
/**
 * Ermöglicht das Anlegen eines neuen Mediums
 * Prüft, ob Artikelnummer schon vorhanden ist und ob alle, für das in der Combobox gewählte Medium, notwendigen Felder ausgefüllt sind.
 * Gibt bei falschen Eingaben Fehlerfenster oder Hinweise in den Textfeldern aus.
 * @param evt = MouseClicked 
 */
    private void but_medienver_anlegenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_but_medienver_anlegenMouseClicked
        
       try{
            int comboselect = combo_medienver_medium.getSelectedIndex();
        
            if(Integer.valueOf(txt_medienver_artikelnummer.getText().compareTo("")) == 0 || Integer.valueOf(txt_medienver_artikelnummer.getText()) <= 0){
                txt_medienver_artikelnummer.setText("ArtNr. falsch/fehlt");
            }
            else{
                int artNumb = Integer.valueOf(txt_medienver_artikelnummer.getText());
            
                if(txt_medienver_titel.getText().compareTo("") == 0){
                    txt_medienver_titel.setText("Titel eingeben");
                }
                else{
                    String titel = txt_medienver_titel.getText();
                
                    if(txt_medienver_genre.getText().compareTo("") == 0){
                        txt_medienver_genre.setText("Genre eingeben");
                    }
                    else{
                        String genre = txt_medienver_genre.getText();
                    
                        if(Double.valueOf(txt_medienver_preis.getText().compareTo("")) == 0 || Double.valueOf(txt_medienver_preis.getText()) <= 0){
                            txt_medienver_preis.setText("ungültig");
                        }
                        else{
                            try{
                                double preis = Double.valueOf(txt_medienver_preis.getText());
                        
                                if(comboselect == 0 || comboselect == 1){
                            
                                    if(txt_medienver_regisseur.getText().compareTo("") == 0){
                                        txt_medienver_regisseur.setText("Regisseur angeben");
                                    }
                                    else{
                                        String regisseur = txt_medienver_regisseur.getText();
                                
                                        if(txt_medienver_hauptdarsteller.getText().compareTo("") == 0){
                                            txt_medienver_hauptdarsteller.setText("Hauptdarsteller");
                                        }
                                        else{
                                            String hauptdarsteller = txt_medienver_hauptdarsteller.getText();
                                            boolean drei_d = check_medienver_drei_d.isSelected();
                       
                                            if(comboselect == 0){
                                                DVD dvd = new DVD(artNumb, titel, genre, preis, 0, regisseur, hauptdarsteller);
                                                mv.anlegen(dvd);
                                                list = mv.getListe();
                                                list_medienver_medienliste.setModel(new MediaListModel(list));
                                            }
        
                                            else if(comboselect == 1){
                                                BlueRay blueray = new BlueRay(artNumb, titel, genre, preis, 0, regisseur, hauptdarsteller, drei_d);
                                                mv.anlegen(blueray);
                                                list = mv.getListe();
                                                list_medienver_medienliste.setModel(new MediaListModel(list));
                                            }
                                        }
                                    }
                                }
                                else{
                                    boolean online = check_medienver_online.isSelected();
                                    boolean move = check_medienver_move.isSelected();
                                    boolean kinect = check_medienver_kinect.isSelected();
                                    boolean gamepad = check_medienver_gamepad.isSelected();
                        
                                    if(comboselect == 2){
                                        PS3 ps3 = new PS3(artNumb, titel, genre, preis, 0, online, move);
                                        mv.anlegen(ps3);
                                        list = mv.getListe();
                                        list_medienver_medienliste.setModel(new MediaListModel(list));
                                    }
        
                                    else if(comboselect == 3){
                                        WiiU wiiu = new WiiU(artNumb, titel, genre, preis, 0, online, gamepad);
                                        mv.anlegen(wiiu);
                                        list = mv.getListe();
                                        list_medienver_medienliste.setModel(new MediaListModel (list));
                                    }
        
                                    else if(comboselect == 4){
                                        XBOX xbox = new XBOX(artNumb, titel, genre, preis, 0, online, kinect);
                                        mv.anlegen(xbox);
                                        list = mv.getListe();
                                        list_medienver_medienliste.setModel(new MediaListModel (list));
                                    }
                                }
                            }catch(NumberFormatException nfe1){
                                txt_medienver_preis.setText("z.B. 3.00");
                            }
                        }
                    }
                }
            }
        }catch(NumberFormatException nfe2){
            txt_medienver_artikelnummer.setText("Keine Buchstaben");
        }
       
    }//GEN-LAST:event_but_medienver_anlegenMouseClicked
/**
 * Ermöglicht das Suchen eines Mediums
 * Prüft, ob Artikelnummer eingegeben wurde und ob Artikelnummeer vorhanden ist.
 * Wenn nicht, werden Fehlerfenster und Hinweise ausgegeben.
 * Ansonsten wird der Titel und das Genre zur Artikelnummer angezeigt.
 * @param evt = MouseClicked
 */
    private void but_medienver_suchenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_but_medienver_suchenMouseClicked
        
        if(txt_medienver_artikelnummer.getText().compareTo("") == 0){
            txt_medienver_artikelnummer.setText("ArNr. eingeben");
            combo_medienver_medium.setSelectedIndex(0);
            txt_medienver_titel.setText("");
            txt_medienver_genre.setText("");
            txt_medienver_regisseur.setText("");
            txt_medienver_hauptdarsteller.setText("");
            txt_medienver_preis.setText("");
            check_medienver_drei_d.setSelected(false);
            check_medienver_online.setSelected(false);
            check_medienver_move.setSelected(false);
            check_medienver_kinect.setSelected(false);
            check_medienver_gamepad.setSelected(false);
            list = mv.getListe();
            list_medienver_medienliste.setModel(new MediaListModel(list));
        }
        
        else
            try{    
                Medium toDisplay = mv.filtern(Integer.valueOf(txt_medienver_artikelnummer.getText()));
                Fehler_ArtSuchen artsu = new Fehler_ArtSuchen();
                if (toDisplay == null)
                        artsu.setVisible(true);
                txt_medienver_artikelnummer.setText(String.valueOf(toDisplay.getArtikelnr()));
                combo_medienver_medium.setSelectedIndex(0);
                txt_medienver_titel.setText(toDisplay.getTitel());
                txt_medienver_genre.setText(toDisplay.getGenre());
                txt_medienver_regisseur.setText("");
                txt_medienver_hauptdarsteller.setText("");
                txt_medienver_preis.setText("");
                check_medienver_drei_d.setSelected(false);
                check_medienver_online.setSelected(false);
                check_medienver_move.setSelected(false);
                check_medienver_kinect.setSelected(false);
                check_medienver_gamepad.setSelected(false);
                list = mv.getListe();
                list_medienver_medienliste.setModel(new MediaListModel(list)); 
                    
            }catch(NumberFormatException nfe){
                txt_medienver_artikelnummer.setText("ArtNr. ungültig");
            }
        
    }//GEN-LAST:event_but_medienver_suchenMouseClicked
/**
 * Ermöglicht das Löschen eines Mediums
 * Prüft, ob Liste leer ist und gibt ansonsten ein Fehlerfenster aus.
 * Wenn die Liste nicht leer ist, dann wird geprüft, ob eine Artikelnummer eingegeben, 
 * oder ob ein Artikel gewählt wurde. Wenn nicht wird ein Fehlerfenster ausgegeben.
 * Wenn alles passt, dann wird das Medium gelöscht
 * @param evt = MouseClicked
 */
    private void but_medienver_loeschenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_but_medienver_loeschenMouseClicked
        
        List<Medium> allMediums = mv.getListe();
        Medium m = (Medium) list_medienver_medienliste.getSelectedValue();
        
        if(allMediums.isEmpty()){
            Fehler_ListeLeer aus = new Fehler_ListeLeer();
            aus.setVisible(true);
        }
        else if(txt_medienver_artikelnummer.getText().compareTo("") == 0 && m == null){
                    Fehler_MV_Auswahl fmva = new Fehler_MV_Auswahl();
                    fmva.setVisible(true);
                    combo_medienver_medium.setSelectedIndex(0);
                    txt_medienver_titel.setText("");
                    txt_medienver_genre.setText("");
                    txt_medienver_regisseur.setText("");
                    txt_medienver_hauptdarsteller.setText("");
                    txt_medienver_preis.setText("");
                    check_medienver_drei_d.setSelected(false);
                    check_medienver_online.setSelected(false);
                    check_medienver_move.setSelected(false);
                    check_medienver_kinect.setSelected(false);
                    check_medienver_gamepad.setSelected(false);
                }
                else{
                    try{
                        if(Integer.valueOf(txt_medienver_artikelnummer.getText().compareTo("")) != 0){
                            int artNumber = Integer.valueOf(txt_medienver_artikelnummer.getText());
                            
                            for(Medium ml : allMediums){
                                if(ml.getArtikelnr() == artNumber && ml.getausgeliehen() != 0){
                                    Fehler_MV_Loeschen fmvl = new Fehler_MV_Loeschen();
                                    fmvl.setVisible(true);
                                }
                                else if(ml.getArtikelnr() == artNumber && ml.getausgeliehen() == 0){
                                    mv.löschen(ml.getArtikelnr());
                                    list = mv.getListe();
                                    list_medienver_medienliste.setModel(new MediaListModel(list));
                                }
                            }
                            
                        }   
        
                        else if(m != null){
                                if(m.getausgeliehen() == 0){
                                mv.löschen(m.getArtikelnr());
                                list = mv.getListe();
                                list_medienver_medienliste.setModel(new MediaListModel(list));
                                }
                                else if(m.getausgeliehen() != 0){
                                    Fehler_MV_Loeschen fmvl = new Fehler_MV_Loeschen();
                                    fmvl.setVisible(true);
                                }
                            }
                
                            else if(m != null && Integer.valueOf(txt_medienver_artikelnummer.getText().compareTo("")) != 0){
                                Fehler_MV_Auswahl fmva = new Fehler_MV_Auswahl();
                                fmva.setVisible(true);
                            }
                            txt_medienver_artikelnummer.setText("");
                            combo_medienver_medium.setSelectedIndex(0);
                            txt_medienver_titel.setText("");
                            txt_medienver_genre.setText("");
                            txt_medienver_regisseur.setText("");
                            txt_medienver_hauptdarsteller.setText("");
                            txt_medienver_preis.setText("");
                            check_medienver_drei_d.setSelected(false);
                            check_medienver_online.setSelected(false);
                            check_medienver_move.setSelected(false);
                            check_medienver_kinect.setSelected(false);
                            check_medienver_gamepad.setSelected(false);
                            list = mv.getListe();
                            list_medienver_medienliste.setModel(new MediaListModel(list));
                        
                        }catch(NumberFormatException nfe){
                            txt_medienver_artikelnummer.setText("ArtNr. ungültig");
                        }
                    }
    }//GEN-LAST:event_but_medienver_loeschenMouseClicked
/**
 * Schließt das Medienverwaltungsfenster
 * @param evt =MouseClicked
 */
    private void but_medienver_zurueckMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_but_medienver_zurueckMouseClicked
        
        dispose();
    }//GEN-LAST:event_but_medienver_zurueckMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MedienverGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MedienverGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MedienverGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MedienverGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MedienverGUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton but_medienver_anlegen;
    private javax.swing.JButton but_medienver_loeschen;
    private javax.swing.JButton but_medienver_suchen;
    private javax.swing.JButton but_medienver_zurueck;
    private javax.swing.JCheckBox check_medienver_drei_d;
    private javax.swing.JCheckBox check_medienver_gamepad;
    private javax.swing.JCheckBox check_medienver_kinect;
    private javax.swing.JCheckBox check_medienver_move;
    private javax.swing.JCheckBox check_medienver_online;
    private javax.swing.JComboBox combo_medienver_medium;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lbl_medienver_artikelnummer;
    private javax.swing.JLabel lbl_medienver_drei_d_modus;
    private javax.swing.JLabel lbl_medienver_gamepad;
    private javax.swing.JLabel lbl_medienver_genre;
    private javax.swing.JLabel lbl_medienver_hauptdarsteller;
    private javax.swing.JLabel lbl_medienver_kinect;
    private javax.swing.JLabel lbl_medienver_medienliste;
    private javax.swing.JLabel lbl_medienver_medium;
    private javax.swing.JLabel lbl_medienver_move;
    private javax.swing.JLabel lbl_medienver_online;
    private javax.swing.JLabel lbl_medienver_preis;
    private javax.swing.JLabel lbl_medienver_preis_euro;
    private javax.swing.JLabel lbl_medienver_regisseur;
    private javax.swing.JLabel lbl_medienver_titel;
    private javax.swing.JList list_medienver_medienliste;
    private javax.swing.JTextField txt_medienver_artikelnummer;
    private javax.swing.JTextField txt_medienver_genre;
    private javax.swing.JTextField txt_medienver_hauptdarsteller;
    private javax.swing.JTextField txt_medienver_preis;
    private javax.swing.JTextField txt_medienver_regisseur;
    private javax.swing.JTextField txt_medienver_titel;
    // End of variables declaration//GEN-END:variables
}
